$TITLE  Model M22: Closed Economy 2X2 with Intermediate Inputs and Nesting

$ONTEXT

                 Production Sectors          Consumers
   Markets  |    X       Y        W    |       CONS
   ------------------------------------------------------
       PX   |  120     -20     -100    |
       PY   |  -20     120     -100    |
       PW   |                   200    |       -200
       PL   |  -40     -60             |        100
       PK   |  -60     -40             |        100
    ------------------------------------------------------
 
$OFFTEXT

PARAMETERS
 TX; 

TX = 0;

$ONTEXT
$MODEL: M22

$SECTORS:
        X       ! Activity level for sector X
        Y       ! Activity level for sector Y
        W       ! Activity level for sector W (Hicksian welfare index)

$COMMODITIES:
        PX      ! Price index for commodity X
        PY      ! Price index for commodity Y
        PL      ! Price index for primary factor L
        PK      ! Price index for primary factor K
        PW      ! Price index for welfare (expenditure function)

$CONSUMERS:
        CONS    ! Income level for consumer CONS

$PROD:X s:0.5  va:1
        O:PX  Q:120
        I:PY  Q: 20
        I:PL   Q:40  va: A:CONS  T:TX
        I:PK   Q:60  va: A:CONS  T:TX

$PROD:Y s:0.75  va:1
        O:PY   Q:120
        I:PX   Q: 20
        I:PL   Q: 60  va:
        I:PK   Q: 40  va:

$PROD:W s:1
        O:PW   Q:200
        I:PX   Q:100
        I:PY   Q:100

$DEMAND:CONS
        D:PW   Q:200
        E:PL   Q:100
        E:PK   Q:100

$OFFTEXT
$SYSINCLUDE mpsgeset M22

PW.FX = 1;

$INCLUDE M22.GEN
SOLVE M22 USING MCP;


*       Counterfactual:  100% tax on X sector inputs:

TX = 1.0;
$INCLUDE M22.GEN
SOLVE M22 USING MCP;


*       Algebraic representation -- note the complexity of two-
*       level CES functions which are automatically generated within
*       MPSGE.


EQUATIONS
        PRF_X   Zero profit for sector X
        PRF_Y   Zero profit for sector Y
        PRF_W   Zero profit for sector W (Hicksian welfare index)

        MKT_X   Supply-demand balance for commodity X
        MKT_Y   Supply-demand balance for commodity Y
        MKT_L   Supply-demand balance for primary factor L
        MKT_K   Supply-demand balance for primary factor L
        MKT_W   Supply-demand balance for aggregate demand

        I_CONS  Income definition for CONS;

PRF_X.. 120 * ( 1/6 * PY**(1-0.5) +
                5/6 * (PL**0.4 * PK**0.6 * (1+TX))**(1-0.5) )**(1/(1-0.5))
                        =E= 120 * PX;

PRF_Y.. 120 * ( 1/6 * PX**(1-0.75) +
                5/6 * (PL**0.6 * PK**0.4)**(1-0.75) )**(1/(1-0.75))  
                        =E= 120 * PY;

PRF_W.. 200 * PX**0.5 * PY**0.5 =E= 200 * PW;

MKT_X.. 120 * X =E= 100 * W * PX**0.5 * PY**0.5 / PX + 20*Y*(PY/PX)**0.75;

MKT_Y.. 120 * Y =E= 100 * W * PX**0.5 * PY**0.5 / PY + 20*X*(PX/PY)**0.5;

MKT_W.. 200 * W =E= CONS / PW;

MKT_L.. 100  =E= 40 * X * (PX/((1+TX)*PL**0.4*PK**0.6))**0.5 
                                * PL**0.4 * PK**0.6 / PL +
                 60 * Y * (PY/(PL**0.6 * PK**0.4))**0.75
                                * PL**0.6 * PK**0.4 / PL;

MKT_K.. 100 =E=  60 * X * (PX/((1+TX)*PL**0.4*PK**0.6))**0.5 
                        * PL**0.4 * PK**0.6 / PK +
                 40 * Y * (PY/(PL**0.6 * PK**0.4))**0.75
                        * PL**0.6 * PK**0.4 / PK;

I_CONS.. CONS =E= 100*PL + 100*PK + 
                  TX * 100 * X * PL**0.4*PK**0.6 * 
                        (PX/((1+TX)*PL**0.4*PK**0.6))**0.5;

MODEL ALGEBRAIC /PRF_X.X, PRF_Y.Y, PRF_W.W, MKT_X.PX, MKT_Y.PY, MKT_L.PL, 
                 MKT_K.PK, MKT_W.PW, I_CONS.CONS /;

*       Check the benchmark:

        X.L=1; Y.L=1; W.L=1; PX.L=1; PY.L=1; PK.L=1; PW.L=1; CONS.L=200;

        TX = 0; 
        SOLVE ALGEBRAIC USING MCP;

*       Solve the same counterfactual:

        TX = 1; 
        SOLVE ALGEBRAIC USING MCP;


$ontext

Excercises:      

1. Revise the X sector production to nest Y with K at the bottom
(Cobb-Douglas) level, and then let these inputs trade off with L 
at the top (CES) nest.  

$PROD:X s:0.5  LY:1
        O:PX  Q:120
        I:PY  Q: 20  LY:
        I:PL   Q:40  A:CONS  T:TX
        I:PK   Q:60  LY: A:CONS  T:TX

Before running TX=1 experiment, guess as to whether this revised
nesting will increase or decrease the excess burden of taxation.  Run
the experiment, and see if the results confirm or contradict your
economit economic intuition.

2. Rewrite the algebraic model in accordance with the new nesting
structure, and verify that you obtain identical solution values.
(This excercise is tedious but educational, with a level of
difficulty roughly comparable to 500 piece jig-saw puzzle.

$offtext
